import math

pi = 3.14159265

def deg2rad(deg):
  return (deg * pi / 180)

def rad2deg(rad):
  return (rad * 180 / pi)

def calculate_distance(lat1, lon1, lat2, lon2):
  theta = lon1 - lon2
  dist = math.sin(deg2rad(lat1)) * math.sin(deg2rad(lat2)) + math.cos(deg2rad(lat1)) * math.cos(deg2rad(lat2)) * math.cos(deg2rad(theta))
  dist = math.acos(dist)
  dist = rad2deg(dist)
  dist = dist * 60 * 1.1515
  dist = dist * 1.609344
  return dist

if __name__ == '__main__':
	print "width", calculate_distance(23.3927307128908, 102.144996643067, 23.3927307128908, 109.469429016114)
	print "height", calculate_distance(8.56333160400391, 102.144996643067, 23.3927307128908, 102.144996643067)